//
//  MySettingOptions.m
//  GIFShow
//
//  Created by lanou11air029 on 15/3/31.
//  Copyright (c) 2015年 CK. All rights reserved.
//

#import "MySettingOptions.h"

@interface MySettingOptions ()
@property (nonatomic, strong) NSArray * colorsArray;
@end

@implementation MySettingOptions
@synthesize mutableLabels = _mutableLabels;

-(void)dealloc{
    
    [super dealloc];
}
+(instancetype) defaultOptions{
    static dispatch_once_t onceToken;
    static MySettingOptions * myOptions = nil;
    dispatch_once(&onceToken, ^{
        myOptions = [[MySettingOptions alloc]init];
    });
    return myOptions;
}
-(instancetype)init{
    self = [super init];
    if (self) {
        self.userDefault = [NSUserDefaults standardUserDefaults];
        self.colorsArray = [NSArray arrayWithObjects:[UIColor blackColor],[UIColor darkGrayColor],[UIColor redColor], [UIColor greenColor], [UIColor blueColor], [UIColor yellowColor], [UIColor magentaColor],[UIColor orangeColor],[UIColor purpleColor],[UIColor brownColor]  , nil];

        if (![self.userDefault boolForKey:@"isFirst"]) {
            self.userFontValue = 18;
            self.contentFontValue = 14;
            self.otherFontValue = 11;
            self.titleFontValue = 17;
            self.myFontColorValue = 2;
            self.isAutoPlay = YES;
            self.isPush = YES;
            self.backColor = @"back01";
            NSArray * titles = [NSArray arrayWithObjects:@"本周最热",@"老外搞笑gif",@"LOL", @"电影出处", @"买买买买买",@"游戏", @"科普贴",@"萌宠",@"牛人",@"熊孩子",@"喵个了咪",@"战斗名族的日常系列",@"动漫", @"神奇机械",@"万万没想到",@"体育",@"基就是正义", nil];
            self.foreGColor = self.colorsArray[self.myFontColorValue];
            self.mutableLabels = [NSMutableArray arrayWithArray:titles];
            [self.userDefault setInteger:18 forKey:@"userFontValue"];
            [self.userDefault setInteger:14 forKey:@"contentFontValue"];
            [self.userDefault setInteger:11 forKey:@"otherFontValue"];
            [self.userDefault setInteger:17 forKey:@"titleFontValue"];
            [self.userDefault setBool:self.isAutoPlay forKey:@"autoPlay"];
            [self.userDefault setBool:self.isPush forKey:@"isPush"];
            [self.userDefault setObject:self.backColor forKey:@"backColor"];
            [self.userDefault setObject:titles forKey:@"titles"];
            [self.userDefault setInteger:self.myFontColorValue forKey:@"fontColor"];
            [self.userDefault setBool:YES forKey:@"isFirst"];
            [self.userDefault synchronize];
           
        }else{
            self.userFontValue = [self.userDefault integerForKey:@"userFontValue"];
            self.contentFontValue = [self.userDefault integerForKey:@"contentFontValue"];
            self.otherFontValue = [self.userDefault integerForKey:@"otherFontValue"];
            self.titleFontValue = [self.userDefault integerForKey:@"titleFontValue"];
            self.backColor = [self.userDefault objectForKey:@"backColor"];
            self.myFontColorValue = [self.userDefault integerForKey:@"fontColor"];
            self.foreGColor = self.colorsArray[self.myFontColorValue];
            [self.userDefault setBool:NO forKey:@"isFirst"];
            [self.userDefault synchronize];
            NSArray * titles = [self.userDefault objectForKey:@"titles"];

            self.mutableLabels = [NSMutableArray arrayWithArray:titles];
        }
    }
    return self;
}

@end
